//
// Created by vcq on 21/4/6.
//
#include "model/require.hpp"
static void GetRequire_Syllabus(request& req, response& res) {
    if (!check_login(req, res)) {
        return;
    }
    basic_string_view<char> id = req.get_query_value("id");
    basic_string_view<char> _require_id = req.get_query_value("_require_id");
    basic_string_view<char> _syllabus_id = req.get_query_value("_syllabus_id");
    basic_string_view<char> _plan_id = req.get_query_value("_plan_id");
    json item = MGetRequireSyllabus(id, _require_id, _syllabus_id, _plan_id);
    res.set_status_and_content(status_type::ok, item.dump(), req_content_type::json);
}
static void SaveRequire_Syllabus(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    struct _require_syllabus _require_syllabus1{};
    _require_syllabus1.id = atoi(req.get_query_value("id").data());
    _require_syllabus1._require_id=atoi(req.get_query_value("_require_id").data());
    _require_syllabus1._syllabus_id = atoi(req.get_query_value("_syllabus_id").data());
    _require_syllabus1._plan_id = atoi(req.get_query_value("_plan_id").data());
    _require_syllabus1.per = atof(req.get_query_value("per").data());
    _require_syllabus1.note=req.get_query_value("note");
    MAddRequireSyllabus(_require_syllabus1);
    res.set_status_and_content(status_type::ok);
}


static void DeleteRequire_Syllabus(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    MDeleteRequireSyllabus(req.get_query_value("id"));
    res.set_status_and_content(status_type::ok);
}
